/*
 * MembershipBO.java
 *
 * Created on February 12, 2007, 9:10 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.group1E.data;

import java.util.Date;
import java.util.*;

/**
 *
 * @author tkulbeth
 */
public class MembershipBO {
    
    private String membershipID = "";
    private String creditCardType = "";
    private String creditCardNum = "";
    private int creditCardExpMonth = 0;
    private int creditCardExpYear = 0;
    private String memberStartDate = null;
    private String memberExpireDate = null;
    private String buExpDate = null;
    private double buSize = 0.0;
    private String membPwd = null;
    private CustomerBO cust = null;
    private ArrayList<AreaOfInterestBO> interestList = null;
    private boolean alreadyInDB = false;
    private boolean isDirty = true;
    
    /** Creates a new instance of MembershipBO */
    MembershipBO(String memberID){
        setAlreadyInDB(false);
        setIsDirty(true);
        this.membershipID = memberID;
    }
    
    /**Creates a MembershipBO using parameters retrieved from the UI or DB**/
    MembershipBO(String memberID, String credidCardNum, String startDate, String expireDate, CustomerBO cust) {
        setMembershipID(memberID);
        setCreditCardNum(getCreditCardNum());
        setMemberStartDate(startDate);
        setMemberExpireDate(expireDate);
        setAlreadyInDB(false);

    }
    

    public CustomerBO getCust() {
        return cust;
    }

    public void setCust(CustomerBO cust) {
        setIsDirty(true);
        this.cust = cust;
    }

    public ArrayList<AreaOfInterestBO> getInterestList() {
        return interestList;
    }

    public void addInterest(AreaOfInterestBO newInterest) {
        setIsDirty(true);
        if(this.getInterestList() == null){
            this.setInterestList(new ArrayList<AreaOfInterestBO>());
        }
        this.getInterestList().add(newInterest);
    }
    
    public void removeInterest(int index) {
        this.getInterestList().remove(index);
    }

    public String getMembershipID() {
        return membershipID;
    }

    public void setMembershipID(String membershipID) {
        setIsDirty(true);
        this.membershipID = membershipID;
    }

    public String getCreditCardType() {
        return creditCardType;
    }

    public void setCreditCardType(String creditCardType) {
        setIsDirty(true);
        this.creditCardType = creditCardType;
    }

    public String getCreditCardNum() {
        return creditCardNum;
    }

    public void setCreditCardNum(String creditCardNum) {
        setIsDirty(true);
        this.creditCardNum = creditCardNum;
    }

    public int getCreditCardExpMonth() {
        return creditCardExpMonth;
    }

    public void setCreditCardExpMonth(int creditCardExpMonth) {
        setIsDirty(true);
        this.creditCardExpMonth = creditCardExpMonth;
    }

    public int getCreditCardExpYear() {
        return creditCardExpYear;
    }

    public void setCreditCardExpYear(int creditCardExpYear) {
        setIsDirty(true);
        this.creditCardExpYear = creditCardExpYear;
    }

    public String getMemberStartDate() {
        return memberStartDate;
    }

    public void setMemberStartDate(String memberStartDate) {
        setIsDirty(true);
        this.memberStartDate = memberStartDate;
    }

    public String getMemberExpireDate() {
        return memberExpireDate;
    }

    public void setMemberExpireDate(String memberExpireDate) {
        setIsDirty(true);
        this.memberExpireDate = memberExpireDate;
    }

    public void setInterestList(ArrayList interestList) {
        setIsDirty(true);
        this.interestList = interestList;
    }

    public boolean isAlreadyInDB() {
        return alreadyInDB;
    }

    public void setAlreadyInDB(boolean alreadyInDB) {
        setIsDirty(true);
        this.alreadyInDB = alreadyInDB;
    }

    /** Sets the idDirty variable
     *@return isDirty
     */
    public boolean isIsDirty() {
        return isDirty;
    }

    /** Sets the isDirty variable
     *@param isDirty indicates if info has been changed
     */
    public void setIsDirty(boolean isDirty) {
        this.isDirty = isDirty;
    }

    /** Returns the backup expiration date
     *@return buExpDate
     */
    public String getBuExpDate() {
        return buExpDate;
    }

    /** Sets the backup expiration date for this member
     *@param buExpDate contains the expiration date for the backup
     */
    public void setBuExpDate(String buExpDate) {
        setIsDirty(true);
        this.buExpDate = buExpDate;
    }

    /** Returns the backup size for this member
     *@return buSize
     */
    public double getBuSize() {
        return buSize;
    }

    /** Sets the backup size for this member
     *@param buSize contains the size of the backup.
     */
    public void setBuSize(double buSize) {
        setIsDirty(true);
        this.buSize = buSize;
    }
    
    /** Returns this member's password
     *@return membPwd
     */
    public String getMembPwd(){
        return this.membPwd;
    }
      
    /** Sets the password for this member
     *@param pwd contains the password for this member
     */
    public void setMembPwd(String pwd){
        setIsDirty(true);
        this.membPwd = pwd;
    }
    
    /** Checks the password entered at the login screen to see if
     *it's correct or not.
     *@param pwd contains the password entered
     *@retun isValid
     */
    public boolean validatePwd(String pwd){
        boolean isValid = false;
        if(pwd.equals(this.membPwd)){
            isValid = true;
        }
        return isValid;
    }
}
